import http from '../api/http'

// 登录
function login(username,password,rememberMe = false){
    const url=`/api/login?username=${username}&password=${password}&rememberMe=${rememberMe}`;
    return http.post(url);
}
// 退出登录
function logout(){
    const url =`/api/logout`;
    return http.get(url);
}
// 短信验证码
function Verification(mobile) {
    const url =`/api/short-message/vcode/${mobile}`;
    return http.get(url);
}
// 忘记密码
function forget (loginName,code,phonenumber,password){
    const url =`/api/password/forget`;
    const formData = new FormData();
    formData.append("loginName",loginName);
    formData.append("code",code);
    formData.append("phonenumber",phonenumber);
    formData.append("password",password);
     // eslint-disable-next-line no-debugger
    return http.post(url,formData);
}
// 注册
function registry(loginName,code,phonenumber,password,userName) {
    const url =`/api/registry`;
    const formData = new FormData();
    formData.append("loginName",loginName);
    formData.append("code",code);
    formData.append("phonenumber",phonenumber);
    formData.append("password",password);
    formData.append("userName",userName);
    return http.post(url,formData);
}
// 修改头像 
function setPortrait(avatarfile) {
    const url = "/api/system/user/profile/update/avatar/nos";
    // 因为是from-data类型 所以需要先构造一个请求体
    const formData = new FormData();
    // 将参数添加到构造函数中
    formData.append("avatarfile",avatarfile);
    // POST请求第一个参数是地址 第二个参数是请求体
    return http.post(url,formData);
}
// 修改个人信息
function information(userName,phonenumber){
    const url = `/api/system/user/profile/update`;
    const formData = new FormData();
    formData.append("phonenumber",phonenumber);
    formData.append("userName",userName);
    return http.post(url,formData);
}
// 查看个人信息
function Look(){
    const url = `/api/login-user/info`;
    return http.get(url);
}
// 收藏列表
function collection(){
    const url = `/api/cms/article/collect/list`;
    return http.get(url);
}
export {
    login,
    logout,
    Verification,
    forget,
    registry,
    setPortrait,
    information,
    Look,
    collection
}